package com.xiaocheng.www.service.base.impl;

import com.xiaocheng.www.mapper.MyMapper;
import com.xiaocheng.www.service.base.BaseService;
import lombok.RequiredArgsConstructor;

import java.util.List;
@RequiredArgsConstructor
public class BaseServiceImpl<T> implements BaseService<T> {

    public final MyMapper<T> myMapper;
    @Override
    public List<T> findAll() {
        return myMapper.selectList(null);
    }

    @Override
    public T findById(Long Id) {
        return  myMapper.selectById(Id);
    }

    @Override
    public List<T> findByIds(List<Long> ids) {
        return myMapper.selectBatchIds(ids);
    }

    @Override
    public int deleteById(Long id) {
        return myMapper.deleteById(id);
    }

    @Override
    public int deleteByIds(List<Long> ids) {
        return myMapper.deleteBatchIds(ids);
    }

    @Override
    public int updateId(T t) {
        return myMapper.updateById(t);
    }

    @Override
    public int addId(T t) {
        System.out.println(t);
        return myMapper.insert(t);
    }
}
